import request from "@/utils/request";

const BASE_URL = "/admin";

const adGroupAPI = {
  /**
   * 编辑
   * @param data
   */
  exportList(data: adGroupPageQuery) {
    return request<any, PageResult<PageVO[]>>({
      url: `${BASE_URL}/content/export/pageList`,
      method: "post",
      data,
    });
  },
  /**
   * 编辑
   * @param data
   */
  updateAdGroupList(data: any) {
    return request({
      url: `${BASE_URL}/content/ad/update`,
      method: "post",
      data,
    });
  },
  /**
   * 添加
   *
   * @param data
   */
  addAdGroupList(data: any) {
    return request({
      url: `${BASE_URL}/content/ad/add`,
      method: "post",
      data,
    });
  },
  /**
   * 批量删除
   *
   * @param ids IDs数组
   */
  deleteAdGroupListByIds(data: any) {
    return request({
      url: `${BASE_URL}/content/ad/del`,
      method: "post",
      data,
    });
  },
  /** 获取通知轮播分页数据 */
  getAdGroupListPage(data?: adGroupPageQuery) {
    return request<any, PageResult<PageVO[]>>({
      url: `${BASE_URL}/content/ad/all`,
      method: "POST",
      data,
    });
  },

  /** 获取通知轮播分页数据 */
  getPage(data?: adGroupPageQuery) {
    return request<any, PageResult<PageVO[]>>({
      url: `${BASE_URL}/content/adGroup/pageList`,
      method: "POST",
      data,
    });
  },

  /**
   * 批量删除
   *
   * @param ids IDs数组
   */
  deleteByIds(data: any) {
    return request({
      url: `${BASE_URL}/content/adGroup/del`,
      method: "post",
      data,
    });
  },

  /**
   * 更新
   *
   * @param id ID
   * @param data 轮播组表单数据
   */
  update(data: Form) {
    return request({
      url: `${BASE_URL}/content/adGroup/update`,
      method: "post",
      data: data,
    });
  },

  /**
   * 轮播组
   *
   * @param data 轮播组表单数据
   * @returns
   */
  add(data: Form) {
    return request({
      url: `${BASE_URL}/content/adGroup/add`,
      method: "post",
      data: data,
    });
  },
};

export default adGroupAPI;

/** 分页查询参数 */
export interface adGroupPageQuery extends PageQuery {
  group_id?: any;
  /** 标题 */
  s_name?: string;
  /** code */
  s_code?: string;
}

/** 分页对象 */
export interface PageVO {
  id: string;
  /** name */
  name?: string;
  /** code */
  code?: string;
  /** 备注 */
  remark?: string;
}

/** 表单对象 */
export interface Form {
  id?: number;
  /** name */
  name?: string;
  /** code */
  code?: string;
  /** 备注 */
  remark?: string;
}
